package com.linked.basemanage.permissioncontrol.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.linked.basemanage.permissioncontrol.bean.po.MenuInfoPO;
import com.linked.basemanage.permissioncontrol.mapper.IMeunInfoMapper;
import com.linked.basemanage.permissioncontrol.service.IMeunInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :dbq
 * @date : 2023/2/22 14:19
 * @description : desc
 */
@Slf4j
@Service
public class MeunInfoServiceImpl implements IMeunInfoService {
    private final ObjectMapper mapper;

    private final IMeunInfoMapper meunInfoMapper;

    @Autowired
    public MeunInfoServiceImpl(ObjectMapper mapper, IMeunInfoMapper meunInfoMapper) {
        this.mapper = mapper;
        this.meunInfoMapper = meunInfoMapper;
    }

    @Override
    public boolean addMenu(MenuInfoPO param) throws Exception {
        return meunInfoMapper.insert(param) > 0;
    }

    @Override
    public List<MenuInfoPO> queryMenuInfoList(MenuInfoPO param) throws Exception {
        QueryWrapper<MenuInfoPO> wrapper = new QueryWrapper<>();
        wrapper.eq("data_status", 1);
        return meunInfoMapper.selectList(wrapper);
    }
}
